<html>
<head>
      <title>a frame which receive the message</title>
     
  <script>
    var OnMessage = function(e) {
      var data = e.data;
      if (data){
        document.write("iframe中接收到数据："+e.data)
        window.parent.postMessage(data, '*');
      }
    }

    function init() {
      if (window.addEventListener) {  // all browsers except IE before version 9
        window.addEventListener('message', OnMessage, false)
      } else {
        if (window.attachEvent) {   // IE before version 9
          window.attachEvent('onmessage', OnMessage)
        }
      }
    }
    init()
  </script>
</head>
<body>
    <p>a iframe to receive the message</p>
</body>
</html>
